<?php
 /*************************************************\
    TV-Program
    Version: 2.5
    Author: Dmitri M. Furmanoff
    E-mail: furik@mail.ru
    \*************************************************/

    /*************************************************\
    Компонент: Телепрограммы
    Версия: 2.3
    Автор: Дмитрий Фурманов
    E-mail: furik@mail.ru
    \*************************************************/

defined ('_VALID_MOS') or die('Доступ к файлу запрещен.');
require_once($mosConfig_absolute_path."/administrator/components/com_tv/config.tv.php");

$cid = mosGetParam( $_REQUEST ,'cid', '' );
$cid=intval($cid);
$isrem=0;
$today=getdate($mostime);
$dayofweek = $today['wday']; 
$dayofweek=$dayofweek?$dayofweek:7;
$i=0;
$wday = mosGetParam($_REQUEST,"wday",-1);

if($wday==-1)
 $wday=$dayofweek-1;
?>
<table border="0" cellspacing="1" cellpadding="3" width="100%">
<tr align="center" class="sectiontableentry2">
<?php
for($i=0;$i<7;$i++)
 if($wday!=$i)
 echo "<th><a href=\"".sefRelToAbs("index.php?option=com_tv&task=channel&cid=$cid&wday=$i")."\">".$a_weeks[$i]."</a></th>\n";
else
 echo "<th>".$a_weeks[$i]."</th>\n";
?>
</tr>
</table>

<?php
$dat=mktime(0,0,0,$today['mon'],$today['mday']-$dayofweek+$wday+1,$today['year']);
$qr="SELECT tc.channelname, tc.channellogo, tp.pid, tp.date, tp.channel, tp.name, tp.hour, tp.minute
FROM #__tvchannels tc
INNER JOIN #__tvprogramms tp ON tc.cid = tp.channel
WHERE tp.date='".date("Y-m-d",$dat)."' AND tc.cid=".$cid." AND tc.published=1
ORDER BY tp.order";
$database->setQuery($qr);
$programms=$database->loadObjectList(); 
?>

<form name=tv_reminder method=post action='<?php sefRelToAbs("index.php?option=com_tv");?>'>
<b><center><?php echo $a_weekl[$wday].", ".date("d.m.Y",$dat);?></center></b>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr><td>
<table width=100% border=0 cellspacing=1>

<?php
$i=0;
foreach($programms as $programm)
{
if($i==0){
     echo "<tr class=sectiontableheader><td colspan=";
     if($my->id)
        echo "3";
     else
        echo "2";   
     echo ">";
     if(strlen($programm->channellogo))
       echo "<img src='$mosConfig_live_site/$pathlogo/$programm->channellogo' border=0 width=40 height=32 align=\"absmiddle\" vspace=2 />";
     else
       echo "<img src='$mosConfig_live_site/images/blank.png' border=0 width=40 height=32 align=\"absmiddle\" vspace=2 />";
     echo "$programm->channelname</td></tr>";
         }
echo "<tr class=sectiontableentry".($i % 2 + 1).">";
if(strlen($filter) && eregi($filter,$programm->name))
  {
  echo "<td width=\"30\"><b>".$programm->hour.":".$programm->minute."</b></td>";
  echo "<td><b>".$programm->name."</b></td>";
  }
else
 {
  echo "<td width=\"30\">".$programm->hour.":".$programm->minute."</td>";
  echo "<td>".$programm->name."</td>";
  }

if($my->id)
{
echo "<td>";
if(strtotime($programm->date)>$mostime)
 {
   echo "<input type=checkbox name=Reminder[] value=".$programm->pid."/>";
   $isrem=1;
 }
echo "&nbsp;</td>";
}
echo "</tr>";

if($showanons)
 {
  $qr="SELECT * FROM #__tvanons WHERE date='".date("Y-m-d",$dat)."' AND channel = ".$programm->channel." AND hour=$programm->hour AND minute=$programm->minute AND about<>''";
 $database->setQuery($qr);
  $anons=$database->loadObjectList();
  if(count($anons)){
    echo "<tr class=sectiontableentry".($i % 2 +1)."><td width=30>&nbsp;</td>";
    echo "<td>".$anons[0]->about."</td>";
 if($my->id)
  {
   echo "<td></td>";
  }
 echo "</tr>";
 }     
}
$i++;
}
echo "</table></td></tr></table>";

echo "<input type=hidden name=task value='reminder'>";
if($isrem)
 echo "<right><input type=submit class='button' value="._TV_BUTTONREMINDER."></right>";
echo "</form>";


?>
